//
//  TwoLineWithDateCell.m
//  CMVRFForIOS
//
//  Created by zhangnorman on 15/6/10.
//  Copyright (c) 2015年 hvacapp. All rights reserved.
//

#import "TwoLineWithDateCell.h"
@interface TwoLineWithDateCell()

@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *stateLabel;
@property (nonatomic,strong) UILabel *detailLabel;
@property (nonatomic,strong) UILabel *dateLabel;

@end

@implementation TwoLineWithDateCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupViews];
    }
    return self;
}

/**
 *  <#Description#>
 */
- (void)setupViews {
    self.contentView.width = kScreen_Width - CELL_PADDING_RIGTH_AND_IMAGE;
    
    self.dateLabel = [UILabel labelSingleLineFontSize:10 content:@"2015-10-30"];
    self.dateLabel.width = self.dateLabel.width + 5;
    self.dateLabel.x = self.contentView.width -  self.dateLabel.width;
    self.dateLabel.textColor = CM_PLACEHOLDER_TEXT_COLOR;
    [self.contentView addSubview:self.dateLabel];
    
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(CELL_PADDING_LEFT, CELL_PADDING_TOP, CGRectGetMaxX(self.dateLabel.frame) - CELL_PADDING_LEFT - CELL_CONTENT_MARGIN, kListTitleFontSize)];
    self.titleLabel.font = [UIFont systemFontOfSize:kListTitleFontSize];
    self.titleLabel.textColor = CM_TABLE_TITLE_COLOR;
    [self.contentView addSubview:self.titleLabel];
    
    self.stateLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.titleLabel.frame), CGRectGetMaxY(self.titleLabel.frame) - kListDetailFontSize, 0, kListTitleFontSize)];
    self.stateLabel.font = [UIFont systemFontOfSize:kListDetailFontSize];
    self.stateLabel.textColor = CM_TABLE_TITLE_COLOR;
    [self.contentView addSubview:self.stateLabel];
    self.stateLabel.hidden = YES;
    
    self.detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(CELL_PADDING_LEFT, CELL_PADDING_TOP + CGRectGetMaxY(self.titleLabel.frame) + CELL_CONTENT_MARGIN, CGRectGetMaxX(self.dateLabel.frame) - CELL_PADDING_LEFT - CELL_CONTENT_MARGIN, kListDetailFontSize)];
    self.detailLabel.font = [UIFont systemFontOfSize:kListDetailFontSize];
    self.detailLabel.textColor = CM_TABLE_DETAIL_COLOR;
    [self.contentView addSubview:self.detailLabel];
    
    self.contentView.height = CGRectGetMaxY(self.detailLabel.frame) + CELL_PADDING_BOTTOM;
    self.dateLabel.centerY = self.contentView.height/2;
}

- (void)setTitleStr:(NSString*)title andDetailStr:(NSString*)detail andDate:(NSString*)dataStr{
    self.stateLabel.hidden = YES;
    self.titleLabel.text = title;
    self.detailLabel.text = detail;
    self.dateLabel.text = dataStr;
}

- (void)setTitleStr:(NSString*)title andStatus:(NSString*)status andStatusColor:(UIColor*)color andDetailStr:(NSString*)detail andDate:(NSString*)dataStr {
    self.titleLabel.text = title;
    self.titleLabel.size = [Tools sizeOfSingleLineText:title withSize:kListTitleFontSize];
    self.stateLabel.hidden = NO;
    self.stateLabel.text = status;
    self.stateLabel.textColor = color;
    self.stateLabel.size = [Tools sizeOfSingleLineText:status withSize:kListDetailFontSize];
    self.stateLabel.x = CGRectGetMaxX(self.titleLabel.frame) + 5;
    self.detailLabel.text = detail;
    self.dateLabel.text = dataStr;
}

- (CGFloat)getHeight {
    return self.contentView.height;
}



@end
